package fr.labri.harmony.analysis.jsep.results;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.lang3.StringEscapeUtils;

import au.com.bytecode.opencsv.CSVReader;

public class CSVToTex {

	public static void main(String[] args) throws IOException {
		String file = "/home/cedric/Documents/Projets/JSEP_2013/logs.csv";
		CSVReader reader = new CSVReader(new InputStreamReader(new FileInputStream(new File(file))), ';', '"', 1);
		String[] nextLine;
		PrintStream ps = new PrintStream(System.out);
		while ((nextLine = reader.readNext()) != null) {
			if (nextLine != null) {
				if(nextLine[1].equals("DATABASE")) {
					String source = nextLine[2];
					String target = nextLine[3];
					String msg = nextLine[4];
					String reason = nextLine[5];
					ps.println("\\textit{"+source+" $~\\rightarrow~$ "+target+ "} & \""+msg+"\" & "+reason+" \\\\");
					ps.println("\\midrule");
				}
			}
		}

		ps.close();
		reader.close();
	}


}
